<template>
    <div class="sidebar">
        <h3 style="text-align: center; margin-bottom: 20px;">导航菜单</h3>
        <ul>
            <li v-for="route in routes" :key="route.path" style="height: 40px; line-height: 40px;margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid #394a56;">
                <router-link :to="route.path" class="nav-link">
                    <div style="text-align: center; width: 100%;">
                        <i :class="route.icon"></i>
                        {{ route.name }}
                    </div>
                </router-link>
            </li>
        </ul>
    </div>
</template>

<script>
export default {
    name: 'Sidebar',
    computed: {
        routes() {
            return this.$router.options.routes.filter(route => route.name);
        }
    }
}
</script>

<style scoped>
.sidebar {
    width: 250px;
    height: 100vh;
    background-color: #2c3e50;
    color: #ffffff;
    padding: 20px;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
}

.sidebar h3 {
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid #394a56;
}

.sidebar ul {
    list-style: none;
    padding: 0;
}

.sidebar ul li {
    margin-bottom: 10px;
}

.nav-link {
    color: #b0bec5;
    text-decoration: none;
    display: flex;
    align-items: center;
    transition: color 0.3s ease;
}

.nav-link i {
    margin-right: 10px;
}

.nav-link:hover,
.nav-link:focus {
    color: #ffffff;
}
</style>
